//
//  HYFNavigationController.m
//  MyOCWeibo
//
//  Created by 黄勇锋 on 16/10/3.
//  Copyright © 2016年 黄勇锋. All rights reserved.
//

#import "HYFNavigationController.h"

@interface HYFNavigationController ()

@end

@implementation HYFNavigationController

- (void)viewDidLoad {
    [super viewDidLoad];

}

- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated{
    
    NSString *title = @"返回";
    
    NSInteger count = self.childViewControllers.count;
    //如果执行到这个地方,判断里面有一个控制器的话,代表当前要往导航控制器里面push的是第二个控制器
    if (count >= 1) {
    
        if (count == 1) {
            
            title = [[self.childViewControllers firstObject] title];
        }
        // 设置在 push 的时候隐藏底部的 tabbar
        viewController.hidesBottomBarWhenPushed = YES;
    
        viewController.navigationItem.leftBarButtonItem = [UIBarButtonItem itemWithImageName:@"navigationbar_back_withtext" title:title target:self action:@selector(back)];
    }
    [super pushViewController:viewController animated:YES];
}

- (void)back{
    
    [self popViewControllerAnimated:YES];
}



@end
